<script type="text/javascript">
	$(document).ready(function() {
            $('.fancybox-media').fancybox({
              openEffect	: 'elastic',
              closeEffect	: 'elastic',
		helpers : {
			media : {}
		}
            });  
           $(".various").fancybox({
              closeClick  : false,
              openEffect	: 'elastic',
              closeEffect	: 'elastic',
              width		: '60%',
              closeBtn          : true,
              height		: '50%',
              type              :'iframe',
              'afterClose' : function() {
                parent.location.reload(true);
              },
              helpers   : {
                overlay : {closeClick: false}
              },
              'hideOnContentClick': true
            });
        });
</script>
<table  class='paginated_table sorted_table table-general'>
  <thead>
  <tr>

    <th>Patrimonio Cultural</th>
    <th>Localización</th>
    <%#*<th>DNI Responsable</th>%>
    <th>Responsable</th>
    <th>Descripción Breve</th>
    <%#*<th>Descripción Completa</th>%>
    <th>Fecha</th>
    <th>Estado</th>
    <th>Opciones</th>
    <th></th>
  </tr>
  </thead>

<% @cultural_heritage_incidences.each do |cultural_heritage_incidence| %>
  <tbody>
  <tr>
    <td><%= cultural_heritage_incidence.obj_cultural_heritage.name %></td>
    <td><%= cultural_heritage_incidence.location %></td>
    <%#*<td><%= cultural_heritage_incidence.dniResponsable </td>%>
    <td><%= cultural_heritage_incidence.fullNameResponsable %></td>
    <td><%= cultural_heritage_incidence.briefDesc %></td>
    <%#*<td><%= cultural_heritage_incidence.completeDesc </td>%>
    <td><%= cultural_heritage_incidence.date_incidence %></td>

    <td><%= cultural_heritage_incidence.str_state %></td>

    <% if cultural_heritage_incidence.state==0 %> <!--NO SE ACEPTA NI SE RECHAZA, EL USUARIO AÚN PUEDE REALIZAR LA MODIFICACIÓN-->
        <td>
          <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), cultural_heritage_incidence %><!--VER-->
          <%= link_to image_tag("navi/pencil-16-ns.png", :border => 0, :title => 'Editar'), edit_cultural_heritage_incidence_path(cultural_heritage_incidence) %><!--EDITAR-->
          <% if user_signed_in? && [1].include?(current_user.role)%> <!-- Miembro de la institución cultural asigna -->
          <%= link_to image_tag("navi/badge-square-check-16-ns.png", :border => 0, :title => 'Atender'), {:action => 'attend_incidence',:id => cultural_heritage_incidence.id}, :confirm => '¿Seguro que desea aceptar la solicitud de Incidencia?' %><!--ACEPTAR-->
          <%= link_to image_tag("navi/badge-square-minus-16-ns.png", :border => 0, :title => 'Denegar'), {:action => 'deny_incidence',:id => cultural_heritage_incidence.id}, :confirm => '¿Seguro que desea rechazar la solicitud de Incidencia?' %><!--RECHAZADA-->
          <%end%>
        </td>
    <%else%>      
      <% if cultural_heritage_incidence.state==1 %><!--ACEPTAR-->
        <% if user_signed_in? && [1].include?(current_user.role)%> <!-- Miembro de la institución cultural asigna Miembro del INC-->
          <td>
            <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), cultural_heritage_incidence %><!--VER-->
            <%= link_to image_tag("navi/person1.png",:size=>'15x15', :border => 0, :title => 'Asignar Miembro INC'), {:controller=>"/cultural_heritage/incidences",:action => 'attend_incidence_inc',:id => cultural_heritage_incidence.id}, :class =>'various', :remote =>true  %><!--aceptar INC-->
          </td>
        <%end%>
     <%elsif cultural_heritage_incidence.state==3 %>
          <% if user_signed_in? && [4].include?(current_user.role)%> <!-- Miembro del INC asigna Jefe del INC-->
            <td>
              <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), cultural_heritage_incidence %><!--VER-->
              <%= link_to image_tag("navi/person2.png",:size=>'15x15', :border => 0, :title => 'Asignar Jefe INC'), {:controller=>"/cultural_heritage/incidences",:action => 'attend_incidence_inc',:id => cultural_heritage_incidence.id}, :class =>'various', :remote =>true  %><!--aceptar INC-->
            </td>
          <%end%>
     <%elsif cultural_heritage_incidence.state==4 %>
         <% if user_signed_in? && [7].include?(current_user.role)%> <!-- Jefe del INC asigna Experto Legal -->
            <td>
              <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), cultural_heritage_incidence %><!--VER-->
              <%= link_to image_tag("navi/person3.png",:size=>'15x15', :border => 0, :title => 'Asignar Experto Legal'), {:controller=>"/cultural_heritage/incidences",:action => 'attend_incidence_inc',:id => cultural_heritage_incidence.id}, :class =>'various', :remote =>true  %><!--aceptar INC-->
            </td>
         <%end%>
      <%else%><!--RECHAZADA-->
        <td>
          <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), cultural_heritage_incidence %><!--VER-->
        </td>
      <%end%>
    <%end%>
    
    <%# if cultural_heritage_incidence.state==1 %>
    <%#*<td>%>
      <%#*<label> A </label>%>
    <%#*</td>%>
    <%#end%>
    

    </tr>
    </tbody>
<% end %>
</table>
